import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 马拉圈
 * Date: 2023-03-12
 * Time: 16:16
 */
public class Search implements Opera{
    public  void opera(Connection connection) throws SQLException {
        String sql = "select * from student";
        PreparedStatement preparedStatement = connection.prepareStatement(sql);
        ResultSet set = preparedStatement.executeQuery();
        int count = 0;
        while(set.next()) {
            int id = set.getInt("id");
            String name = set.getString("name");
            System.out.println("id = " + id  + ", name = " + name);
            count++;
        }
        System.out.println(count + "rows 被影响~");
        set.close();
        preparedStatement.close();
    }
}
